#socket
#客户端
import socket
#1.创建socket对象
socket_client = socket.socket()
#2.连接到服务器
socket_client.connect(("localhost",8888))
while True:
    #3.发送消息
    msg = input("输入发送给服务端的信息:")
    if msg == 'exit':
        break
    socket_client.send(msg.encode("UTF-8"))

    #4.接收消息
    recv_data = socket_client.recv(1024)
    print(f"服务器回复的消息:{recv_data.decode("UTF-8")}")
#5.关闭连接
socket_client.close()
